<template>
  <div class="dashboard-editor-container">
    <!-- 红色标题区域 -->
    <!--    <div class="dashboard-header">-->
    <!--      <h1 class="dashboard-title">死亡人数统计分析</h1>-->
    <!--      <div class="dashboard-subtitle">实时监控与数据可视化</div>-->
    <!--    </div>-->

    <!-- 上方两个饼图 -->
    <el-row :gutter="24" class="top-charts">
      <el-col :xs="24" :sm="24" :lg="12">
        <el-card class="chart-card">
          <div slot="header" class="chart-header">
            <span class="chart-title">死亡人数男女占比图</span>
          </div>
          <div class="chart-wrapper">
            <pie-chart :chartData="sexPieData"/>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="12">
        <el-card class="chart-card">
          <div slot="header" class="chart-header">
            <span class="chart-title">各年龄段占比图</span>
          </div>
          <div class="chart-wrapper">
            <age-pie-chart :chartData="agePieData"/>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 下方折线图 -->
    <el-card class="chart-card line-chart-card">
      <div slot="header" class="chart-header">
        <span class="chart-title">近六个月死亡人数走势图</span>
      </div>
      <div class="chart-wrapper">
        <line-chart :chartData="numberLineData"/>
      </div>
    </el-card>
  </div>
</template>

<script>
import {homePage} from'@/api/index/index'
import LineChart from './dashboard/LineChart'
import PieChart from './dashboard/PieChart'
import agePieChart from './dashboard/agePieChart.vue'

export default {
  name: 'Index',
  components: {
    LineChart,
    PieChart,
    agePieChart
  },
  data() {
    return {
      sexPieData: null,
      agePieData:  null,
      numberLineData: null,

    }
  },
  created() {
    this.handleAllData()
  },
  methods: {
    handleAllData() {
      homePage().then(response => {
        console.log("response",response.data)
        this.sexPieData = response.data.part1
        this.agePieData = response.data.part2
        this.numberLineData = response.data.part3
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 10px 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  min-height: 100vh;
  position: relative;

  .dashboard-header {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    padding: 24px 32px;
    margin: -24px -24px 32px -24px;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.3);
    text-align: center;

    .dashboard-title {
      color: white;
      font-size: 32px;
      font-weight: 700;
      margin: 0 0 12px 0;
      text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
      letter-spacing: 1px;
    }

    .dashboard-subtitle {
      color: rgba(255, 255, 255, 0.95);
      font-size: 18px;
      font-weight: 400;
      letter-spacing: 0.5px;
    }
  }

  .top-charts {
    margin-bottom: 1px;

    .el-col {
      margin-bottom: 1px;
    }
  }

  .chart-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
    transition: all 0.3s ease;
    height: 100%;

    &:hover {
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
      transform: translateY(-4px);
    }

    .chart-header {
      border-bottom: 1px solid #f0f2f5;
      padding: 20px 24px;
      background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
      border-radius: 12px 12px 0 0;

      .chart-title {
        color: #dc3545;
        font-size: 20px;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;

        &::before {
          content: '';
          display: inline-block;
          width: 6px;
          height: 20px;
          background: #dc3545;
          margin-right: 12px;
          border-radius: 3px;
          box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
        }
      }
    }
  }

  .line-chart-card {
    .chart-header {
      .chart-title {
        font-size: 22px;

        &::before {
          height: 24px;
        }
      }
    }
  }

  .chart-wrapper {
    padding: 20px;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  // 响应式调整
  @media (max-width: 1200px) {
    .dashboard-header {
      padding: 20px 24px;

      .dashboard-title {
        font-size: 28px;
      }

      .dashboard-subtitle {
        font-size: 16px;
      }
    }

    .chart-card {
      .chart-header {
        padding: 0px 20px;

        .chart-title {
          font-size: 18px;
        }
      }
    }
  }

  @media (max-width: 768px) {
    .dashboard-editor-container {
      padding: 16px;
    }

    .dashboard-header {
      padding: 16px 20px;
      margin: -16px -16px 24px -16px;
      border-radius: 0 0 12px 12px;

      .dashboard-title {
        font-size: 24px;
      }

      .dashboard-subtitle {
        font-size: 14px;
      }
    }

    .chart-card {
      .chart-header {
        padding: 12px 16px;

        .chart-title {
          font-size: 16px;
          justify-content: flex-start;

          &::before {
            width: 4px;
            height: 16px;
            margin-right: 8px;
          }
        }
      }
    }

    .chart-wrapper {
      padding: 12px;
      min-height: 300px;
    }
  }

  @media (max-width: 480px) {
    .dashboard-header {
      .dashboard-title {
        font-size: 20px;
      }
    }

    .chart-card {
      .chart-header {
        .chart-title {
          font-size: 14px;
        }
      }
    }
  }
}

// 全局卡片样式优化
::v-deep .el-card__body {
  padding: 0;
}

::v-deep .el-card__header {
  padding: 0;
  border-bottom: none;
}
</style>
